home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / gfx / edit / VE-batchpro.lha / progs / dirutil / opus5 / arexx / VisualBatchProcess.dopus5
Encoding:
Text File  |  1999-07-16  |  2.5 KB  |  165 lines

  1. /*
  2.  
  3.    v1.00 BatchProcess (for Magellan)
  4.  
  5.    Marko Seppänen
  6.    marko.seppanen@wwnet.fi
  7.  
  8. */
  9.  
  10. /* Visual batch processing for Magellan
  11.  
  12. $VER: VisualBatchProcess.dopus5 1.00 (16.7.1999)
  13.  
  14. */
  15.  
  16.  
  17. options results
  18.  
  19. if show("P","DOPUS.1") then address "DOPUS.1"
  20. else Exit
  21.  
  22.  
  23.  
  24.  
  25. x=arg(1)
  26. parse var x sourcedir file .
  27.  
  28.  
  29.  
  30. /* DO WE HAVE IMAGE ENGINEER AVAILABLE?" */
  31.  
  32. if ~show('P',IMAGEENGINEER) then do
  33.  
  34.   if exists('IE:IE') then do
  35.  
  36.     address command 'Run >NIL: IE:IE'
  37.     do 30 while ~SHOW('P',IMAGEENGINEER)
  38.       address command 'wait >nil: 1'
  39.     end
  40.  
  41.     if ~show('P',IMAGEENGINEER) then do
  42.       say "Could not open Image Engineer's Arexx-port for some reason."
  43.       say "Exiting.."
  44.     end
  45.  
  46.   end
  47.   else do
  48.     say "But where's the Image Engineer?!"
  49.     say "Exiting.."
  50.     exit
  51.   end
  52.  
  53. end
  54.  
  55.  
  56.  
  57.  
  58. /* OK. LET'S CONTINUE */
  59.  
  60. address IMAGEENGINEER
  61. signal on error
  62.  
  63. IE_TO_FRONT
  64.  
  65. if ~exists(sourcedir||"processed") then address command "makedir "sourcedir"processed"
  66.  
  67.  
  68.  
  69.  
  70. /* LOAD FILE */
  71.  
  72. OPEN "'"sourcedir||file"'" COLOUR
  73. newfile=result
  74. PROJECT_SET newfile ZOOM "1:16"
  75.  
  76.  
  77.  
  78.  
  79. /* DO SOMETHING */
  80.  
  81. address command "Sys:Rexxc/rx ie:arexx/VisualBorderDemo.rexx" newfile ROUNCORNER 90 13
  82.  
  83. PROJECT_LIST
  84. xyz=result
  85. newpic=subword(xyz,1,1)
  86.  
  87. CLOSE newfile
  88.  
  89.  
  90.  
  91.  
  92. /* SAVE FILE */
  93.  
  94. lastp=lastpos(".",file)
  95. if lastp ~== "0" then do
  96.   oldsuffix=right(file,length(file)-lastp)
  97.   basename=left(file,lastp-1)
  98. end
  99. else basename=strip(substr(file,1,27),B," ")
  100.  
  101.  
  102.  
  103. select
  104.  
  105.   when upper(oldsuffix) == "JPG" | upper(oldsuffix) == "JPEG" | upper(oldsuffix) == "JFIF" then do
  106.    filetype="JPEG (IJG-JFIF)"
  107.    suffix=".jpg"
  108.   end
  109.  
  110.   when upper(oldsuffix) == "PNG" upper(oldsuffix) == "PING" then do
  111.    filetype="PNG (PiNG)"
  112.    suffix=".png"
  113.   end
  114.  
  115.   when upper(oldsuffix) == "TGA" | upper(oldsuffix) == "TARGA" then do
  116.    filetype="Targa (TGA)"
  117.    suffix=".tga"
  118.   end
  119.  
  120.   when upper(oldsuffix) == "TIF" | upper(oldsuffix) == "TIFF" then do
  121.    filetype="TIFF V5.0"
  122.    suffix=".tif"
  123.   end
  124.  
  125.   otherwise do
  126.    filetype="JPEG (IJG-JFIF)"
  127.    suffix=".jpg"
  128.   end
  129.  
  130. end
  131.  
  132.  
  133.  
  134. endpart=right(sourcedir,1)
  135. if endpart~=":" & endpart~="/" then sourcedir=sourcedir||"/"
  136.  
  137. newdir="processed/"
  138. fullpath=sourcedir||newdir||basename||suffix
  139.  
  140.  
  141. SAVE_DATA newpic '"'fullpath'"' '"'filetype'"'
  142.  
  143. CLOSE newpic
  144.  
  145.  
  146.  
  147.  
  148. exit
  149.  
  150.  
  151.  
  152. error:
  153. if RC=5 then do
  154.     IE_TO_FRONT
  155.     LAST_ERROR
  156.     'REQUEST "'||RESULT||'"'
  157.     exit
  158. end
  159. else do
  160.     IE_TO_FRONT
  161.     LAST_ERROR
  162.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  163.     exit
  164. end
  165.